package com.example.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;

/**
 * @Date 2020/10/20 10:22
 * @description：
 */
public class SqlSessionFactoryUtil {

    private static SqlSessionFactory sessionFactory = null;

    public static SqlSessionFactory getSessionFactory() throws IOException {
        if (sessionFactory == null) {
            synchronized (SqlSessionFactoryUtil.class) {
                if (sessionFactory == null) {
                    sessionFactory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("sqlMapConfig.xml"));
                }
            }
        }
        return sessionFactory;
    }
}
